package aiku.numericalcontroloa.Controller.DepartmentManagement;

import aiku.numericalcontroloa.Base.Utils.Result;
import aiku.numericalcontroloa.Model.Dto.DepartmentManagement.DepartmentDto;
import aiku.numericalcontroloa.Service.DepartmentManagement.DepartmentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 部门
 * @Author 黄广庭
 * @Date 2024/2/19 14:12
 */
@RestController
@RequestMapping("/department")
@Slf4j
public class DepartmentController {
    private final DepartmentService departmentService;

    public DepartmentController(DepartmentService departmentService) {
        this.departmentService = departmentService;
    }

    /**
     * 添加部门
     * @param departmentDto
     * @return
     */
    @PostMapping("/addDepartment")
    public Result addDepartment(@RequestBody DepartmentDto departmentDto){
        return departmentService.addDepartment(departmentDto);
    }

    /**
     * 删除部门
     * @param departmentDto
     * @return
     */
    @PostMapping("/deleteDepartment")
    public Result deleteDepartment(@RequestBody DepartmentDto departmentDto){
        return departmentService.deleteDepartment(departmentDto);
    }

    /**
     * 修改部门
     * @param departmentDto
     * @return
     */
    @PostMapping("/updateDepartment")
    public Result updateDepartment(@RequestBody DepartmentDto departmentDto){
        return departmentService.updateDepartment(departmentDto);
    }

    /**
     * 获取部门列表（树形结构）
     * @return
     */
    @PostMapping("/getDepartmentList")
    public Result getDepartmentList(){
        return departmentService.getDepartmentList();
    }

    /**
     * 获取部门列表（非树形结构）
     * @return
     */
    @PostMapping("/selectDepartments")
    public Result selectDepartments(){
        return departmentService.selectDepartments();
    }

    /**
     * 获取部门详情
     * @param departmentDto
     * @return
     */
    @PostMapping("/getDepartment")
    public Result getDepartment(@RequestBody DepartmentDto departmentDto){
        return departmentService.getDepartment(departmentDto);
    }
}
